gtk-demo: Use a native file chooser in the svg demo
authorMatthias Clasen <mclasen@redhat.com>
Fri, 4 Dec 2020 00:44:45 +0000 (19:44 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 4 Dec 2020 00:44:45 +0000 (19:44 -0500)
demos/gtk-demo/paintable_svg.c

index 9d87f121ac03c2246c63ca263e8696ba57857d5a..a1c97721e19d11ad34f6efc225b50f728cc47149 100644 (file)
 
 
 static void
-open_response_cb (GtkWidget  *dialog,
-                  int         response,
-                  GtkPicture *picture)
+open_response_cb (GtkNativeDialog *dialog,
+                  int              response,
+                  GtkPicture      *picture)
 {
-  gtk_widget_hide (dialog);
+  gtk_native_dialog_hide (dialog);
 
   if (response == GTK_RESPONSE_ACCEPT)
     {
@@ -31,7 +31,7 @@ open_response_cb (GtkWidget  *dialog,
       g_object_unref (file);
     }
 
-  gtk_window_destroy (GTK_WINDOW (dialog));
+  gtk_native_dialog_destroy (dialog);
 }
 
 static void
@@ -39,24 +39,20 @@ show_file_open (GtkWidget  *button,
                 GtkPicture *picture)
 {
   GtkFileFilter *filter;
-  GtkWidget *dialog;
+  GtkFileChooserNative *dialog;
 
-  dialog = gtk_file_chooser_dialog_new ("Open node file",
+  dialog = gtk_file_chooser_native_new ("Open node file",
                                         GTK_WINDOW (gtk_widget_get_root (button)),
                                         GTK_FILE_CHOOSER_ACTION_OPEN,
-                                        "_Cancel", GTK_RESPONSE_CANCEL,
-                                        "_Load", GTK_RESPONSE_ACCEPT,
-                                        NULL);
+                                        "_Load",
+                                        "_Cancel");
 
   filter = gtk_file_filter_new ();
   gtk_file_filter_add_mime_type (filter, "image/svg+xml");
   gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
-
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
-  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
+  gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
   g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), picture);
-  gtk_widget_show (dialog);
+  gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
 }
 
 static GtkWidget *window;